<?php
function video_render_item($data){
	$vl=video_get_infor($data['url']);

	$str.='<div class="col-md-15 col-sm-3 col-lg-6 col-xs-4 col-xxs-6 col-xxxs-12">';
						$str.='<div class="video-featured-item">';
												$str.='<a class="wrap-featured-item-img" href="'.video_url_item($data['id'],$data['alias']).'"><img class="featured-item-img lazy" data-original="http://i.ytimg.com/vi/'.$vl['v'].'/mqdefault.jpg" alt="'.$data['name'].'" />';
                                            	$str.='<span class="views badge">'.$data['view'].' views</span>';
                                            $str.=' </a>';
											$str.='<h4>';
												$str.='<a href="'.video_url_item($data['id'],$data['alias']).'">'.$data['name'].'</a>';
												$str.='<span class="paragraph-end"></span>';
											$str.='</h4>';
											
											 $str.='<div class="row video-featured-item-new-chapt hidden-xs">';
												 $str.='<div class="col-md-6">';
												 $str.='<a title="Cuộc chiến không cân sức" href="'.video_url_user($data['upload_user']).'">'.$data['upload_user'].'</a>';
												$str.='</div>';
                                               $str.='<div class="col-md-6" style="font-size: 11px; line-height: 20px;">';
                                                $str.=time_ago($data['upload_time']);
                                                $str.='</div>';
                                             $str.='</div> ';
	
					$str.='</div>';
	$str.='</div>';
return $str;
}



function video_render_item_row($data){
	if($data){
			$num=count($data);
			$rows=ceil($num/5);
				for($i=0;$i<$rows;$i++){
						$j=$i*5;
						$dt=array_slice($data,$j,5);
						$str.='<div class="panel-featured-row">';
						foreach($dt as $row){
								$str.=video_render_item($row);
						}
						$str.='<div class="clr"></div>';
						$str.='</div>';
				}
			return $str;	
	}
}


function video_render_item_left($data){
	$vl=video_get_infor($data['url']);

	$str.='<div class="video-small-item ">';
										$str.='<a class="small-image-item" href="'.video_url_item($data['id'],$data['alias']).'"><img class="img-responsive" src="http://i.ytimg.com/vi/'.$vl['v'].'/mqdefault.jpg" alt="" /><span class="views badge">'.$data['view'].' views</span></a>';
										$str.='<a class="small-title" href="'.video_url_item($data['id'],$data['alias']).'">'.$data['name'].'</a>';
                                       $str.=' <div class="row featured-item-new-chapt hidden-xs">';
                                        	$str.='<div class="col-md-6">';
                                            	$str.='<a href="'.video_url_user($data['upload_user']).'">'.$data['upload_user'].'</a>';
                                           $str.=' </div>';
                                            $str.='<div class="col-md-6">';
                                                $str.=time_ago($data['upload_time']);
                                            $str.='</div>';
                                       $str.=' </div>'; 
										
										$str.='<div class="clr"></div>';
									$str.='</div>';
return $str;

}

function video_render_slide_box($data,$alias,$max,$title){

?>
	<div class="my-panel video-panel" id="<?php echo $alias; ?>-panel">
		          
                <input type="hidden" id="<?php echo $alias; ?>-slider-total-page" name="<?php echo $alias; ?>-slider-total-page" value="<?php echo $max; ?>" />
                <input type="hidden" id="<?php echo $alias; ?>-slider-current-page" name="<?php echo $alias; ?>-slider-current-page" value="1" />
                
                <div class="panel-title">
                         <span class="video-panel-title-a"><?php echo $title;?></span> 
                </div>
                 <?php if($data){?>
            <button type="button" class="btn btn-default slide-btn slide-btn-left" id="<?php echo $alias; ?>-btn-slider-prev" data-rel="<?php echo $alias; ?>"><i class="fa fa-arrow-circle-left fa-lg"></i></button>	
			<button type="button" class="btn btn-default slide-btn slide-btn-right" id="<?php echo $alias; ?>-btn-slider-next" data-rel="<?php echo $alias; ?>"><i class="fa fa-arrow-circle-right fa-lg"></i></button>
            
  		
                <div  id="<?php echo $alias; ?>-wrapper" class="slider-wrapper" data-href="1">
                    <div class="wrap-loading" id="wrap-<?php echo $alias; ?>-loading" style="display: none;">
                            <span class="loading" id="<?php echo $alias; ?>-loading"><img alt="loading" src="public/images/loading11.gif"></span><br>
                    </div>
                            
                    <div id="<?php echo $alias; ?>-content-slide-1" class="<?php echo $alias; ?>-content">
                        <?php echo video_render_item_row($data); ?>
                    </div> <!-- End of $alias-content -->
                
                </div> <!-- End of $alias-wrapper -->
                <?php }else{?>
                	<h4 style="text-align:center; font-weight:lighter">DỮ LIỆU ĐANG CẬP NHẬT</h4>
                <?php }?>
            </div> <!-- End my panel class -->
<?php
}
function video_render_related_tag($data,$tag){
	$str='';
	if($data){

							$str.='<div class="right-section" id="related-video">';
                                $str.='<div class="right-title">';
									$str.='<span class="video-panel-title-a">Video liên quan</span>';
								$str.='</div>';
								$str.='<div class="right-content" id="right-content-related-video">';
								
								foreach($data as $row){
									$str.=video_render_item_left($row);
								}
			
								$str.='</div>';
								$str.='<div class="video_more_item"><a href="'.video_url_tag(khongdau($tag)).'">HIỂN THỊ THÊM</a></div>';
								$str.='</div>';

	}
	return $str;
}
function video_render_related_user($data,$user){
	$str='';
	if($data){

							$str.='<div class="right-section" id="related-video">';
                                $str.='<div class="right-title">';
									$str.='<span class="video-panel-title-a">Cùng Người Đăng</span>';
								$str.='</div>';
								$str.='<div class="right-content" id="right-content-related-video">';
								
								foreach($data as $row){
									$str.=video_render_item_left($row);
								}
			
								$str.='</div>';
								$str.='<div class="video_more_item"><a href="'.video_url_user($user).'">HIỂN THỊ THÊM</a></div>';
								$str.='</div>';

	}
	return $str;
}

function video_render_mobile_menu(){
		$val=video_get_all_category();
		$str='';
		foreach($val as $row){
			$str.='<div style="text-align:left"><a href="'.$row['url'].'"  class="panel-odd" style="font-size:20px; font-weight:lighter">'.$row['name'].'</a></div>';
			if($row['sub']){
				foreach($row['sub'] as $row2){
						$str.='<a href="'.$row2['url'].'" class="badge">'.$row2['name'].'</a>';
				}
			}
		}
		return $str;
}